class CreateSalesFinanceInfos < ActiveRecord::Migration[5.1]
  def change
    create_table :sales_finance_infos do |t|
      t.string :name, comment: '抬头'
      t.integer :invoice_type, comment: '个人/公司'
      t.string :tax_num, comment: '纳税人识别号'
      t.string :bank_name, comment: '开户行'
      t.string :account_num, comment: '银行账号'
      t.string :invoice_address, comment: '账单地址'
      t.string :phone, comment: '电话'
      t.string :notes, comment: '备注'
      t.integer :firm_id, comment: '相关公司'
      t.integer :contact_id, comment: '相关联系人'
      t.boolean :as_default, comment: '默认开票'
      t.boolean :active, comment: '是否可用', default: true

      t.timestamps
    end

    add_index :sales_finance_infos, :name
    add_index :sales_finance_infos, :invoice_type
    add_index :sales_finance_infos, :firm_id
    add_index :sales_finance_infos, :contact_id
    add_index :sales_finance_infos, :active
    add_index :sales_finance_infos, :as_default
  end
end
